package com.zw.gulimall.product;

import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class Person {
    String name;
    int age;


    void eat(){
        System.out.println(age+name+"在吃饭");
    }

    public static void main(String[] args) {
        Person.walk();
        new Person().walk();
//        List<? extends Object> list = new ArrayList<Object>();
//        list.add("asda");
//        System.out.println(list);
//        List<String> list1 = null;
//        List<Object> list2 = list1;

        System.out.println(Integer.compare(24,23));
        Customer customer = s -> s+"nihao";
        System.out.println(customer.printStr("zw"));
        Momo momo = new Momo();
        Customer customer1 = new Customer() {
            @Override
            public String printStr(String s) {
                return momo.setName(s);
            }
        };
        Customer customer2 = (str)-> momo.setName(str);
        Customer customer3 = momo::setName;

        Consumer<String> consumer = System.out ::println;
        consumer.accept("你好");
        Stream.iterate(1,t->t*2).limit(10).forEach(System.out::println);
        Stream.generate(Math::random).limit(10).forEach(System.out::println);

        List<String> strings = Arrays.asList("aa", "bb", "bb");
        strings.stream().map(String::toUpperCase).forEach(System.out::println);
    }

    static void walk(){
        System.out.println("i am  walking");
    }
    class Head{
         String name = "头";
        public void eat(String name){
            System.out.println("我时负责吃饭的部位");
            Person.this.eat();
            System.out.println(name);
            System.out.println(this.name);
            System.out.println(Person.this.name);
        }
    }

    @Test
    public void test1(){
        List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6, 7);
        integers.stream().map((e)->e*2).forEach(System.out::println);
        Integer sum = integers.stream().map((e) -> e * 2).reduce(0, Integer::sum);
        System.out.println(sum);
    }
}

